package han.chensing.latos.maker.windows.menus.negative;

import com.badlogic.gdx.scenes.scene2d.ui.TextButton;

import java.util.ArrayList;

import han.chensing.latos.maker.V;
import han.chensing.latos.maker.windows.dialog.base.BaseDialog;
import han.chensing.latos.maker.windows.menus.negative.impl.FileNavigationMenu;
import han.chensing.latos.maker.windows.menus.negative.impl.LevelNavigationMenu;
import han.chensing.latos.maker.windows.menus.negative.impl.SamplesNavigationMenu;
import han.chensing.latos.maker.windows.menus.popup.RightClickMenu;

public class NavigationBar extends BaseDialog {
    public NavigationBar() {
        super("Tool bar",false);
        setKeepWithinStage(true);
        setPosition(0, V.HEIGHT);
        setMovable(false);
        setHeight(50);
        ArrayList<TextButton> buttons = new ArrayList<>();
        buttons.add(new CMenuButton("File", (event, x, y) ->
                showNewMenu(1,new FileNavigationMenu())));
        buttons.add(new CMenuButton("Sample",(event, x, y) ->
                showNewMenu(2,new SamplesNavigationMenu())));
        buttons.add(new CMenuButton("Level", (event, x, y) ->
                showNewMenu(3,new LevelNavigationMenu())));
        int everyWidth = 70;
        int nowX = -everyWidth;
        for (TextButton button : buttons) {
            button.setBounds(nowX += everyWidth, 0, everyWidth, 30);
            addActor(button);
        }
        setWidth(nowX + everyWidth);
    }

    public void showNewMenu(int num,RightClickMenu.RightClickMenuList navigationMenuList){
        RightClickMenu newRightClickMenu = RightClickMenu.getNewRightClickMenu(70 * (num - 1), getY(), navigationMenuList);
        V.container.addWindow(newRightClickMenu);
    }
}
